{extend name="index/base" /} {block name="content"}
<blockquote class="layui-elem-quote fhui-admin-main_hd">
	<h2>添加文章</h2>
</blockquote>
<form class="layui-form layui-form-pane" lay-filter="articlefomr">
	<div class="layui-form-item">
		<label class="layui-form-label">标题</label>
		<div class="layui-input-block">
			<input name="title" autocomplete="off" value="" placeholder="标题"
				class="layui-input" type="text" required lay-verify="title">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">文章内容</label>
		<div class="layui-input-block">
			<textarea name="content" class="content" id="content"
				style="height: 300px;"></textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">排序</label>
		<div class="layui-input-block">
			<input name="sort" autocomplete="off" value="" placeholder="排序，越大越靠前"
				class="layui-input" type="number" required lay-verify="required">
		</div>
	</div>
	<div class="layui-form-item">

		<a class="layui-btn layui-btn-primary do-action" onclick="goback(-1)">返回</a>
		<button class="layui-btn" lay-filter="*" lay-submit="">
            提交
        </button>
	</div>

</form>
{/block} {block name="js"}
<script src="/static/ueditor/ueditor.config.js" type="text/javascript"></script>
<script src="/static/ueditor/ueditor.all.min.js" type="text/javascript"></script>
<script type="text/javascript">
	var editor = new UE.ui.Editor({
		toolbars: [
		    ['fullscreen', 'source', 'undo', 'redo','bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc']
		]
	});
	editor.render("content");
	layui.use([ 'form' ], function() {
		var form = layui.form;
        var token = layui.sessionData('token').token;
    	var $ = layui.$;
		form.on('submit(*)', function(data){
            console.log(data.field); //当前容器的全部表单字段，名值对形式：{name: value}
            $.post('{:url("tdmin/Article/addArticle")}?token='+token,data.field,function(res){
                layer.msg(res.desc);
                if(res.code==0){
                    window.location.href="{:url('index')}";
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
	})
</script>
{/block}
